window.onload = function () {
  init()
};

async function init() {
    var order = await ajaxGet("/order/findDeBoy");
    let str = "";
    for (let i = 0; i < order.length; i++) {
        let orderObj = order[i];
        str += `<tr>
                    <td>${orderObj.orderId}</td>
                    <td>${orderObj.person}</td>
                    <td>${orderObj.phone}</td>
                    <td>${orderObj.total}</td>
                    <td><a href="javascript:finish(${orderObj.orderId})">结账</a></td>
                </tr>`;
    }
    $("orderInfo").innerHTML = str
}

async function finish(orderId) {
    var info = await ajaxGet("/order/finish",{
        id:orderId
    });
    if(info == "ok"){
        location.href = "/html/send/sendProduct.html"
    }else {
        alert("结账失败请重试")
    }
}